package com.lagou.rmi.client;

import com.lagou.rmi.pojo.User;
import com.lagou.rmi.service.IUserService;

import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @description:
 * @author: yx
 * @date: 2021/11/23 16:39
 */
public class RmiClient {

    public static void main(String[] args) {
        try {
            //
            Registry registry = LocateRegistry.getRegistry("127.0.0.1", 9998);
            IUserService userService = (IUserService) registry.lookup("userService");
            User remoteUser = userService.getById(1);
            System.out.println(remoteUser);
        } catch (RemoteException | NotBoundException e) {
            e.printStackTrace();
        }

    }
}
